import React, { Component } from "react";
import ReactDOM from 'react-dom';
import {store} from "../help/global.js";
import * as actions from "../actions/index.js"


export default class AddTodo extends Component {
    addClick(){
        const input=this.refs.input
        const text=input.value.trim()
        store.dispatch(actions.addTodo(text))
        input.value=""
    }

    render() {
        return (
            <div>
                <div>
                    <input type="text" ref="input"/>
                    <button onClick={e=>{
                        this.addClick()
                    }}>添加待办项</button>
                </div>
            </div>
        )
    }
}